using System.Reflection;
using Autofac;
using Module = Autofac.Module;

namespace rbac.api;

/// <summary>
/// Autofac????????
/// </summary>
public class AutofacModuleRegister:Module
{
    protected override void Load(ContainerBuilder builder)
    {
        builder.RegisterAssemblyTypes(
                    Assembly.Load("rbac.services")
                    ,Assembly.Load("rbac.contracts")
                )
            .Where(a => a.Name.EndsWith("Service")).AsImplementedInterfaces(); 
        
        builder.RegisterAssemblyTypes(
                Assembly.Load("rbac.domain")
            )
            .Where(a => a.Name.EndsWith("Repository")).AsImplementedInterfaces();

        
        builder.RegisterType<TokenService>();
        
    }
}